package task3
import org.junit.After
import org.junit.Before
import org.junit.Test
import static org.junit.Assert.*
class DepartmentIntegrationTests {

    @Before
    void setUp() {
        // Setup logic here
    }

    @After
    void tearDown() {
        // Tear down logic here
    }

      @Test
   void testSave() {
        def depart= new Department(name: "Инновации")
        assertNotNull  depart.save()
        assertNotNull  depart.id
        def foundDepart= Department.get( depart.id)
        assertEquals "Инновации", foundDepart.name

   }
    @Test
    void testUpdate() {
        def depart = new Department(name: "Инновации")
        assertNotNull depart.save()
        def foundDepart = Department.get(depart.id)
        foundDepart.name = "Празнество"
        foundDepart.save()

        def editDepart = Department.get(depart.id)
        assertEquals "Празнество", editDepart.name
    }

    @Test
    void testDelete(){
        def depart = new Department(name: "Инновации")
        assertNotNull depart.save()

        def foundDepart = Department.get(depart.id)

        foundDepart.delete()

        assertFalse(Human.exists(foundDepart.id))

    }
}
